package com.explorati.design_pattern.creational.singleton.example;

import java.util.HashMap;
import java.util.Map;

import com.mysql.jdbc.StringUtils;

public class ContainerInstance {

	private static Map<String, Object> singletonMap = new HashMap<>();
	
	public static void putInstance(String key, Object instance){
		if(!StringUtils.isNullOrEmpty(key) && instance != null){
			if(!singletonMap.containsKey(key)){
				singletonMap.put(key, instance);
			}
		}
	}
	
	private ContainerInstance(){}
	
	public static Object getInstance(String key){
		return singletonMap.get(key);
	}
}
